﻿<script type="text/javascript">
    var toolbar_yunshugongsi = [{
        text: '新增运输公司',
        iconCls: 'icon-add',
        handler: function() {
            $("#yunshugongsi-edit").dialog("open");
            $("#yunShuGongSiID").val('');
            $("#info-yunshugongsimingcheng").textbox('setValue', '');
            $("#info-yunshugongsizhuangtai").textbox('setValue', '启用');
        }
    }, '-', {
        text: '修改运输公司',
        iconCls: 'icon-edit',
        handler: function() {
            var curRow = $("#xinxi_yunshugongsi").datagrid('getSelected');
            if (curRow) {
                $("#yunshugongsi-edit").dialog("open");
                $("#yunShuGongSiID").val(curRow.id);
                $("#info-yunshugongsimingcheng").textbox('setValue', curRow.gongsimingcheng);
                $("#info-yunshugongsizhuangtai").textbox('setValue', curRow.gongsizhuangtai);
            }
            else {
                alert("请选择要修改的运输公司信息。");
            }
        }
    }, '-', {
        text: '删除运输公司',
        iconCls: 'icon-remove',
        handler: function() {
            $("#yunshugongsi-dlg").dialog("open");
        }
}];

function DelYunShuGongSi() {
    var curRow = $("#xinxi_yunshugongsi").datagrid('getSelected');
    if (curRow) {
        $.post('handler/xinxi_yunshugongsi.ashx', { yunShuGongSiType: "3", yunShuGongSiID: curRow.id,uid:window.uid,kid:window.kid }, function(data, status) {
            if (data == "OK") {
                $("#yunshugongsi-dlg").dialog('close');
                $("#xinxi_yunshugongsi").datagrid('load');
                return;
            }
            if (data == "Failed") {
                alert("删除运输公司信息失败，请重试");
                $("#biaoduan-dlg").dialog('close');
                return;
            }
            alert(data);
            $("#yunshugongsi-dlg").dialog('close');
        });
    }
    else {
        alert("请选择要删除的运输公司信息。");
    }

}
function submitYunShuGongSiForm() {

    var yunshugongsimingcheng = $("#info-yunshugongsimingcheng").textbox('getText');
    var yunshugongsizhuangtai = $("#info-yunshugongsizhuangtai").combobox('getText');
    var yunshugongsiid = $("#yunShuGongSiID").val();
    if (yunshugongsimingcheng && yunshugongsizhuangtai) {
        $.post('handler/xinxi_yunshugongsi.ashx', { uid: window.uid, kid: window.kid, yunShuGongSiType: '2', yunShuGongSiID: yunshugongsiid,yunshugongsimingcheng:yunshugongsimingcheng,yunshugongsizhuangtai:yunshugongsizhuangtai }, function (data, status) {
            if (data == "OK") {
                $("#yunshugongsi-edit").dialog('close');
                $("#xinxi_yunshugongsi").datagrid('load');
                return;
            }
            if (data == "Failed") {
                alert("保存运输公司信息失败，请重试");
                return;
            }
            alert(data);
        });
    }
    else {
        alert("信息不完整，请检查重试。");
    }

}

function clearYunShuGongSiForm() {
    $("#yunshugongsi-edit").dialog('close');
}
$.parser.onComplete = function () {
    $("#xinxi_yunshugongsi").datagrid({
        url: 'handler/xinxi_yunshugongsi.ashx',
        method: 'post',
        queryParams: { yunShuGongSiType: '1',uid:window.uid,kid:window.kid }
    });
}
</script>
<table id="xinxi_yunshugongsi" style=" width:100%" class="easyui-datagrid" title="运输公司管理" data-options="border:false,singleSelect:true,collapsible:false,striped:true,toolbar:toolbar_yunshugongsi">
    <thead>
        <tr>
            <th data-options="field:'gongsimingcheng',width:200">
                运输公司名称
            </th>
            <th data-options="field:'gongsizhuangtai',width:100">
                状态
            </th>
            <th data-options="field:'id',hidden:true">
              编号
            </th>
        </tr>
    </thead>
</table>


<div id="yunshugongsi-edit" class="easyui-dialog" title="运输公司信息编辑" data-options="modal:true,closed:true,iconCls:'icon-edit',draggable:false,collapsible:false,minimizable:false,maximizable:false,resizable:false"
    style="width: 500px; height: 220px; padding: 10px;">
    <div style="width: 350px; margin: 0 auto;">
        <table cellpadding="5" style="font-size: 13px; margin: 0 auto; padding-top: 20px">
            <tr>
                <td>
                    运输公司名称:
                </td>
                <td>
                    <input class="easyui-textbox" type="text" id="info-yunshugongsimingcheng" name="info-yunshugongsimingcheng"
                        data-options="width:200"></input>
                </td>
            </tr>
            <tr>
                <td>
                    状态:
                </td>
                <td>
                    <select class="easyui-combobox" name="info-yunshugongsizhuangtai" id="info-yunshugongsizhuangtai"
                        data-options="width:200, panelHeight: 'auto',editable:false">
                        <option value="启用" selected="true">启用</option>
                        <option value="禁用">禁用</option>
                    </select>
                </td>
            </tr>
        </table>
        <input type="hidden" name="yunShuGongSiID" id="yunShuGongSiID" value="" />
        <div style="text-align: center; padding: 5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" style="width: 75px" onclick="submitYunShuGongSiForm()"
                data-options="iconCls:'icon-ok'">保存</a> <a href="javascript:void(0)" class="easyui-linkbutton"
                    style="width: 75px" onclick="clearYunShuGongSiForm()" data-options="iconCls:'icon-cancel'">关闭</a>
        </div>
    </div>
</div>
<div id="yunshugongsi-dlg" class="easyui-dialog" title="删除确认" style="width: 300px; height: 150px;
    padding: 10px" data-options="
				iconCls: 'icon-help',
				buttons: '#yunshugongsi-dlg-buttons',
				modal:true,
				closed:true
			">
    确定要删除该运输公司信息吗？
</div>
<div id="yunshugongsi-dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:DelYunShuGongSi();">
        确定</a> <a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#yunshugongsi-dlg').dialog('close')">
            取消</a>
</div>